<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@page import="java.sql.*" %><!-- 数据库操作需要 -->   
<%@page import="beans.*" %>
<%@page import="java.util.List" %>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
<link rel="stylesheet" href="UC_style.css">
<style>
#div_main1{	
	width:95%;
	background:white;
	padding:10px;
}
.sec{
	height:25px;
	width:150px;
}
.text1{
	height:25px;
	width:150px;
}
.button_Select{
		background-color:RGB(64,158,255);
    	border-width: 1px;
    	color: white;
    	padding: 5px 10px;
    	margin:10px;
    	width: 66.7px;
   	 	text-align: center;
    	font-size: 16px;
    	border-radius: 12px;
	}
.button_Select:hover {
    background-color:RGB(38,169,226);
}
.a1{
	font-size:13px;
}
.a1:hover {
    color: blue;
}
.tr1{
	background-color:white;
	font-size:12px;
}
.tr1:hover{
	background-color: RGB(160,207,255);
	
}
.tr1:hover td{background:none;}
.tr2{
	background-color:RGB(249,249,249);
	font-size:12px;
}
.tr2:hover{
	background-color: RGB(160,207,255);
	
}
.tr2:hover td{background:none;}
</style>
</head>
<body>
<%

	String first=(String)request.getAttribute("first");
	String EpID=request.getParameter("EpID");
	String time=request.getParameter("time");
	String ok= request.getParameter("ok");
	String addok=(String)request.getAttribute("addok");
	if(ok!=null)
	{
		if(first!=null)
		{
			EpID=(String)request.getAttribute("EpID");
			time=(String)request.getAttribute("time");
		}
			
	}
	if(EpID!=null)
	{
		EpID=EpID.replace(" ", "");
		if(EpID.equals(""))
			EpID=null;
	}
	if(time!=null)
	{
		time=time.replace(" ", "");
		if(time.equals(""))
			time=null;
	}	
	if(addok!=null)
	{
	%>
	<script type="text/javascript">
		alert("提交成功！");
	</script>
	<% }	
	
	//System.out.println("jsp:EpID:"+EpID+"time:"+time);
	if(first==null)
	{
		request.setAttribute("action", "C_Check_Search");
	%>
		<script type="text/javascript">
			var EpID = '<%= EpID %>';
	    	var time ='<%= time %>';
	    	var url = "C_Servlet?action=C_Check_Search&tt=1&EpID=" + EpID + "&time=" + time;
	    	window.location.href = url;
			/*window.location.href="C_Servlet?action=C_Check_Search&tt=1&EpID=${EpID}&time=${time}";*/
		</script>
	<% 
	}
	String ID=(String)session.getAttribute("ID");
	
	//System.out.println("#time:"+time);
	if(time!=null&&!time.equals("null"))
	{
		if(time.charAt(5)=='0')
			time=time.substring(0, 5)+time.substring(6);
		if(time.charAt(7)=='0')
			time=time.substring(0, 7)+time.substring(8);
	}
	
	//String EpID=request.getParameter("EpID");
	//String time=request.getParameter("time");
	
	//System.out.println("EpID:"+EpID+"OK:"+ok);
	

	List <CarRequestBean> list=(List<CarRequestBean>)request.getAttribute("allUsers");
	//System.out.println(""+list);
%>	
	<div class="main" style="background-color:white " >
		
		<div id="header2">
			<img src="img/首页.png" alt="Big Boat" width="30" height="30" style=" vertical-align: middle;">
			首页>用车管理>用车审核
		</div>
		<div id="div_main1">
		<form action="C-Use_Check.jsp" method="post">
			<table border="1" >
				<tr >
					<td width="300px" align="left" style="border:none;" >
						<b>申请人工号</b>&nbsp;&nbsp;<input type="text" class="text1" name="EpID" >
					</td >
					<td width="600px" align="left" style="border:none" >
						<b>申请日期</b>&nbsp;&nbsp;&nbsp;&nbsp;
						<input type="date" style="height:25px;width:150px;" name="time" >
					</td>
					
					<td width="300px" align="center" style="border:none">
						<input type="hidden" name="ok" value="1">
						<input type="submit" class="button_Select" id="select" value="查询" >
						<!-- <input type="button" class="button_Select" id="select" value="审核"> -->
						
						<input type="button" class="button_Select" id="select" value="退回" style="background:rgb(245, 108, 108)">
						
					</td>
				</tr>
			</table>
		</form>
		</div>
		<div id="div_main1" style="background-color:white ;">
			<table  border="1" cellspacing = "0" style="font-size:15px;">
				<tr style="background-color:RGB(228,228,228)" >
					<td height="40px"  width="300px" align="center" style="border:none">
						<b>申请编号</b>
					</td>
					<td width="400px" align="center" style="border:none">
						<b>申请人工号</b>
					</td>
					<td width="300px" align="center" style="border:none">
						<b>申请日期</b>
					</td >
					
					<td width="250px" align="center" style="border:none">
						<b>紧急程度</b>
					</td>
					
					<td width="400px" align="center" style="border:none">
						<b>用车时间</b>
					</td>
					<td width="300px" align="center" style="border:none">
						<b>乘车人数</b>
					</td>
					
					<td width="500px" align="center" style="border:none">
						<b>前往地点</b>
					</td>
					<td width="200px" align="center" style="border:none">
						<b>车牌号</b>
					</td>
					<td width="300px" align="center" style="border:none">
						<b>驾驶员</b>
					</td>
					
					<td width="300px" align="center" style="border:none">
						<b>流程状态</b>
					</td>
					
					<td width="325px" align="center" style="border:none">
						<b>操作</b>
					</td>
				</tr>
			<%	int count=0;
			if(list!=null){
				for(int i=0;i<list.size();i++)
				{ 
					String UseTime=list.get(i).getUseTime();
					UseTime=UseTime.replace("T", " ");
					String RequestID=list.get(i).getRequestID();
					String Status=list.get(i).getStatus();
					String EmpID=list.get(i).getEmpID();
					String applyTime=list.get(i).getapplyTime();
					//System.out.println("Time:"+time+"EpID"+EpID+"1");
					//System.out.println("list.get(i).getlicense_plate():"+list.get(i).getlicense_plate());
					
					if(!Status.equals("待审核"))
							continue;
					if(EpID!=null&&time!=null&&!time.equals("null")&&!EpID.equals("null"))
					{	
						if(!EpID.equals(EmpID)||!time.equals(applyTime))
							continue;		
					}
					else if(EpID.equals("null")&&!time.equals("null"))
					{
						if(!time.equals(applyTime))
							continue;
					}
					else if(!EpID.equals("null")&&time.equals("null"))
					{
						if(!EpID.equals(EmpID))
							continue;
					}
					count++;
					if(count%2==1)
					{
			%>
					<tr class="tr1" >
						<td height="40px"  width="300px" align="center" style="border:none">
							<%=RequestID %>
						</td>
						<td width="300px" align="center" style="border:none">
							<%=EmpID %>
						</td>
						<td width="300px" align="center" style="border:none">
							<%=applyTime %>
						</td >
						
						<td width="250px" align="center" style="border:none">
							<%=list.get(i).getdegree() %>
						</td>
						
						<td width="400px" align="center" style="border:none">
							<%=UseTime%>
						</td>
						<td width="200px" align="center" style="border:none">
							<%=list.get(i).getUsersNum() %>
						</td>
						<td width="500px" align="center" style="border:none">
							<%=list.get(i).getgoPlace() %>
						</td>
						<td width="200px" align="center" style="border:none">
							<%=list.get(i).getlicense_plate()%>
						</td>
						<td width="300px" align="center" style="border:none">
							<%=list.get(i).getDid() %>
						</td>
						<td width="300px" align="center" style="border:none">
							<%=list.get(i).getStatus() %>
						</td>
						<td width="325px" align="center" style="border:none">
							<a class="a1" >查看</a>
							<%String checkURL="C_Servlet?action=C_CheckSingle_Search&RequestID="+RequestID+"&ID="+ID; %>
							<a class="a1" href=<%=checkURL %>>审核</a>
							
						</td>
					</tr>
					<%}else{ %>
						<tr class="tr2" >
						<td height="40px"  width="300px" align="center" style="border:none">
							<%=RequestID %>
						</td>
						<td width="300px" align="center" style="border:none">
							<%=EmpID %>
						</td>
						<td width="300px" align="center" style="border:none">
							<%=applyTime %>
						</td >
						
						<td width="250px" align="center" style="border:none">
							<%=list.get(i).getdegree() %>
						</td>
						
						<td width="400px" align="center" style="border:none">
							<%=UseTime%>
						</td>
						<td width="200px" align="center" style="border:none">
							<%=list.get(i).getUsersNum() %>
						</td>
						<td width="500px" align="center" style="border:none">
							<%=list.get(i).getgoPlace() %>
						</td>
						<td width="200px" align="center" style="border:none">
							<%=list.get(i).getlicense_plate() %>
						</td>
						<td width="300px" align="center" style="border:none">
							<%=list.get(i).getDid() %>
						</td>
						<td width="300px" align="center" style="border:none">
							<%=list.get(i).getStatus() %>
						<td width="325px" align="center" style="border:none">
							<a class="a1" >查看</a>
							<%String checkURL="C_Servlet?action=C_CheckSingle_Search&RequestID="+RequestID+"&ID="+ID; %>
							<a class="a1" href=<%=checkURL %>>审核</a>
							
						</td>
					</tr>
					<%} %>
			<%} }%>							
			</table>
		</div>
	</div>

</body>
</html>